<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class kst_import_data_pdt extends MY_Controller {
	
	function __construct()
	{
		parent::__construct(); 
		
		$this->load->model('kst_import_data_pdt_model', 'PDT');
		$this->secure_session();
	}
	
	function index(){
		$data['title'] = "Setup Import Data PDT";
		viewByTemplate('kst_import_data_pdt/index', $data, 'grid');
	}
	
	function getdata()
	{
		$this->secure_session();
		echo $this->PDT->GetJSON();
	}

	// private function validation()
	// {
	// 	$error = new ErrorList();

	// 	// Get Error Template
	// 	$tpl_empty = $this->MessageTemplate("ER001");
	// 	$tpl_duplicate = $this->MessageTemplate("ER002");
	// 	// Validation
		
	// 	if (post("kemasan") == '') {
	// 		$error->Add("kemasan", "Kemasan", $tpl_empty);
	// 	}else if (post("isi") == '') {
	// 		$error->Add("isi", "Isi Kemasan", $tpl_empty);
	// 	}else if (post("mode") == "create" && intval($this->get_data("SELECT 1 FROM kst_kemasan WHERE kemasan = '".@ereg_replace("[^a-zA-Z0-9_-]", "",@strtoupper(@trim(post("kemasan"))))."' and isi=".post("isi")."")) > 0) {
	// 		$error->Add("kemasan", "Kemasan", $tpl_duplicate);
	// 	}
	// 	return $error;
	// }
	
	// function ajax_post()
	// {
	// 	$is_error = 0;
	// 	$ls_response = "";
	// 	$ls_genid = "";

	// 	$error = $this->validation();
	// 	try
	// 	{
	// 		if (count( $error->Get() ) > 0) { $is_error = 1; }
	// 		else
	// 		{
	// 			// Fill Post Data
	// 			$data	= post_by_key(array('id_kemasan', 'kemasan', 'isi'));
	// 			$data['id_kemasan']	= @ereg_replace("[^a-zA-Z0-9_-]", "",@strtoupper(@trim($data['id_kemasan'])));
				
	// 			if (post("mode") == "create")
	// 			{
	// 				$this->Kemasan->Add($data);

	// 				$ls_response = "Data Tersimpan";

	// 			}
	// 			else if (post("mode") == "edit")
	// 			{
					
	// 				$this->Kemasan->Update($data, array('id_kemasan'	=> $data['id_kemasan']));

	// 				$ls_response = "Data Tersimpan [edited]";
	// 			}
	// 		}
	// 	} catch(Exception $e) {
	// 		$is_error = 1; $ls_response = $e->getMessage();
	// 	}
		
	// 	echo $this->PostResponse(json_encode(array(	'is_error'	=> $is_error,
	// 												'fields'	=> $error->GetDictionary(),
	// 												'msg'		=> $ls_response,
	// 												'genid'		=> $ls_genid,
	// 												'form_sender'=> post("form_sender"))
	// 							));
	// }

	// function ajax_delete()
	// {
	// 	$ls_result	= "";
	// 	$id_kemasan	= get('id_kemasan');
		
	// 	if ($id_kemasan != "")
	// 	{
	// 		// Delete Single
	// 		$arr_rule	= array('id_kemasan' => $id_kemasan);
	// 		$ls_result = $this->Kemasan->DeleteSingle($arr_rule);

	// 	}
	// 	else
	// 	{
			
	// 		$num_row = intval($this->data['num_row']['deleted']);
			
	// 		for ($i = 0; $i < $num_row; $i++)
	// 		{
	// 			$row	= $this->data['deleted'][$i];
				
	// 			$arr_rule	= array('id_kemasan' => $row['id_kemasan']);
	// 			$ls_result .= $this->Kemasan->DeleteSingle($arr_rule);
	// 		}
	// 	}
		
	// 	echo $ls_result;
	// }
}
?>